/**
 * Created by Administrator on 2022/8/30.
 */
interface USB {
    void openDevice();
    void colseDevice();
}
class Mouse implements USB {
    public void openDevice() {
        System.out.println("打开鼠标");
    }
    public void colseDevice() {
        System.out.println("关闭鼠标");
    }
    public void click() {
        System.out.println("点击鼠标");
    }
}

class Keyboard implements USB {
    public void openDevice() {
        System.out.println("打开键盘");
    }
    public void colseDevice() {
        System.out.println("关闭键盘");
    }
    public void click() {
        System.out.println("点击键盘");
    }
}

class Computer {
    public void openComputer() {
        System.out.println("打开电脑");
    }
    public void colseComputer() {
        System.out.println("关闭电脑");
    }

    public void usbDevice(USB usb) {
        usb.openDevice();
        if (usb instanceof Mouse) {
            Mouse mouse = (Mouse) usb;
            mouse.click();
        } else if (usb instanceof Keyboard) {
            Keyboard keyboard = (Keyboard) usb;
            keyboard.click();
        }
        usb.colseDevice();
    }
}
public class Test2 {
    public static void main(String[] args) {
        Computer computer = new Computer();
        computer.openComputer();
        computer.usbDevice(new Mouse());
        computer.usbDevice(new Keyboard());
        computer.colseComputer();
    }
}
